package com.conpany;

import java.util.Scanner;

public class CEception2 {
    public static void main(String[] args) {
        int MAX =4;
        Scanner in=new Scanner(System.in);
        String a=null;
        do{
            try{
                System.out.println("Enter a string (DONE to stop):");
                a=in.nextLine();
                if(a.length()>MAX){
                    throw new StringTooLException("too many keys！");
                }
            }
            catch (StringTooLException e){
                System.out.println("Too much message!");
            }
        }while(!a.equals("DONE"));
    }
}
